﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace FlexiCommerce.Web.UI.DynamicData
{
    public class DynamicParameterCollection : ParameterCollection
    {
        private readonly Type[] _knownTypes = new Type[] {typeof(InExpressionParameter)};

        protected override object CreateKnownType(int index)
        {
            int baseTypesLength = base.GetKnownTypes().Length;
            if (index < baseTypesLength)
                return base.CreateKnownType(index);

            return Activator.CreateInstance(_knownTypes[index - baseTypesLength]);
        }

        protected override Type[] GetKnownTypes()
        {
            List<Type> knownTypes = new List<Type>(base.GetKnownTypes());
            knownTypes.AddRange(_knownTypes);
            return knownTypes.ToArray();
        }

    }
}
